/*
 * @Author: szx
 * @Date: 2022-03-16 14:59:11
 * @LastEditTime: 2022-03-16 15:07:36
 * @Description:
 * @FilePath: \leetcode\剑指offer\04\04.js
 */
/**
 * @param {number[][]} matrix
 * @param {number} target
 * @return {boolean}
 */
var findNumberIn2DArray = function (matrix, target) {
    const m = matrix.length;
    if (m == 0) return false;
    const n = matrix[0].length;
    if (n == 0) return false;
    let x = 0,
        y = n - 1;
    while (x < m && y >= 0) {
        if (target == matrix[x][y]) return true;
        else if (target < matrix[x][y]) y--;
        else x++;
    }
    return false;
};
